<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport"
	content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<meta name="msapplication-tap-highlight" content="no" />
<title>X5</title>
<style type="text/css">
.btn {
	display: inline-block;
	margin-bottom: 0;
	font-weight: normal;
	text-align: center;
	vertical-align: middle;
	cursor: pointer;
	background-image: none;
	border: 1px solid transparent;
	white-space: nowrap;
	padding: 8px 12px;
	font-size: 14px;
	line-height: 1.42857143;
	border-radius: 4px;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	color: #ffffff;
	background-color: #3399f3;
	border-color: #3399f3;
}
</style>
</head>
<body style="margin: 0; padding: 0">
	<script type="text/javascript" src="cordova.js"></script>
	<script type="text/javascript">
		var deviceready = false;
		document.addEventListener('deviceready', function() {
			deviceready = true;
			setTimeout(function() {
				navigator.splashscreen.hide();
			}, 2000)
		}, false);

		function scan() {
			if (!deviceready) {
				alert("扫描失败，cordova尚未初始化完成");
				return;
			}

			cordova.plugins.barcodeScanner.scan(function(result) {
				document.getElementById('url').value = result.text;
				window.location.href = result.text;
			}, function(error) {
				alert("扫描失败：" + error);
			});
		};
	</script>

	<div
		style="padding-top: 20px; padding-bottom: 20px; background-color: #3399f3">
		<div style="padding: 8px; height: 40px">
			<div style="width: 100%; margin: 0; margin-left: -45px; float: left;">
				<div style="margin-right: 25px; margin-left: 45px;">
					<input
						style="width: 100%; height: 42px; font-size: 20px; border: 0; padding-left: 4px; padding-right: 4px"
						id="url" placeHolder="输入URL（http://ip:port）或者点下方按钮扫描输入"
						value="http://x5.justep.com" />
				</div>
			</div>
			<div style="width: 45px; margin: 0; float: left;">
				<button class="btn" style="width: 45px; font-size: 20px"
					onclick="window.location.href=document.getElementById('url').value">></button>
			</div>
		</div>
	</div>

	<div style="padding-top: 20px; height: 80px">
		<button class="btn" style="width: 100%; height: 100%; font-size: 20px"
			onclick="scan()">扫描输入URL</button>
	</div>
</body>
</html>
